<?php
	require("libraries/student.php");
	class Votes extends Student{
		public function __construct(){
			parent::__construct();
			$this->load->model("model_vote");
			$this->load->library("string");
			$this->load->helper("form");
			$this->load->library("form_validation");
		}
		public function index(){
			$config['base_url'] = base_url().'admin/votes/index/';
			$config['total_rows'] = $this->model_vote->count_all();
			$data['title'] ="Manager comments";
			$data['template'] = "votes/list_vote";
			$config['per_page'] = 10;
			$config['uri_segment'] = 4;
			$config['next_link'] = "Next";
			$config['prev_link'] = "Prev";
			$this->load->library("pagination");
			$this->pagination->initialize($config); 
			$start = $this->uri->segment(4);
			$data['data']['votes']= $this->model_vote->listcate($config['per_page'],$start);
			$this->load->view("layout",$data);
		}
		public function active(){
			$id   	= $this->uri->segment(4);
			$status	= $this->uri->segment(5);
			$db = array(
				"votet_status" => $status 
			);
			$this->model_vote->update_status($db,$id);
			redirect(base_url()."admin/votes/");
		}
		public function view(){
			$id = $this->uri->segment(4);
			$data['title'] = "View comment";
			$data['template'] = "votes/detail_vote";
			$data['data'] = "";
			$data['detail']   = $this->model_vote->getdata($id);
			if($data['detail'] == NULL){
				redirect(base_url()."admin/index");
			}
			$data['ship'] = $this->model_vote->getship($data['detail']['sheep_id']);
			$this->load->view("layout",$data);
		}
		public function del(){
			$id = $this->uri->segment(4);
			$this->model_vote->del($id);
			redirect(base_url()."admin/votes/index");
		}
	}